
using System;
using System.Collections;
using CUtil;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
using System.Threading;

namespace CUtil
{
	/// <summary>
	/// abstract basic class
	/// </summary>
	public abstract class BasicID
	{
		private static int nID = -1;
        

		public BasicID()
		{
			nID++;
		}

		public int ID
		{
			get
			{
				return nID;
			}
			set
			{
				nID = value;
			}
		}
	}
	/// <summary>
	/// VALUES STRUCTURE  represents all the values that are used for accessing arrays in the library
	/// These were originally global variables in the original c++ ( yuk )
	/// </summary>
	public struct Values
	{
		/// <summary>
		/// standard values for all networks
		/// </summary>
		public const int NodeValue = 0;
		public const int LearningRate = 1;
		public const int NodeError = 0;
		public const int Weight = 0;

		/// <summary>
		/// BackPropagation Network Values
		/// </summary>
		public const int Delta = 1;
		public const int Momentum = 2;

		/// <summary>
		/// Self Organizing Network Values
		/// </summary>
		public const int Composite = 0;
		public const int Row = 1;
		public const int Column = 2;

		/// <summary>
		/// Bidirectional Associative Memory
		/// </summary>
		public const int LastNodeValue = 1;

       

		/// <summary>
		/// return a random value
		/// Note: The sleep( 100 ) is added as the Random function is called repeatedly in certain cases and
		/// the output is useless on a fast computer so this slows it down enough to make the values acceptable
		/// </summary>
		/// <param name="dLowerLimit">The lowest acceptable value</param>
		/// <param name="UpperLimit">The highest acceptable value</param>
		/// <returns></returns>
		public static double Random( double dLowerLimit, double dUpperLimit, int sleepValue )
		{
            Thread.Sleep(sleepValue);
			double dNumber = 0.0;
			Random temp = new Random();
			dNumber = temp.Next( ( int )dLowerLimit, ( int )dUpperLimit );
			if( dNumber > 0 )
			{
				dNumber -= temp.NextDouble();
				if( dNumber < -1 )
					dNumber = -1;
			}
			else
			{
				dNumber = temp.NextDouble();
				if( dNumber > 1 )
					dNumber = 1;
			}

			return dNumber;
		}

	}


}
